//
//  YSFooterView.swift
//  新浪浪
//
//  Created by mac on 16/3/2.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class YSFooterView: UIView {

    var footViewModel:YSStatusViewModel? {
        didSet{
            retweetButton.setTitle(footViewModel?.retweetString, forState: UIControlState.Normal)
        }
    }
    
    
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    /*
     * 千万不要忘记调用
     */
    private func setupUI(){
//    backgroundColor = UIColor.grayColor()
//        backgroundColor = UIColor.greenColor()
        backgroundColor = UIColor.blackColor()
        addSubview(retweetButton)
        addSubview(commentsButton)
        addSubview(goodButton)
        
        let leftLine = getLine()
        let rightLine = getLine()
        addSubview(leftLine)
        addSubview(rightLine)
        //添加约束
        retweetButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
            //重要约束
            make.width.equalTo(commentsButton.snp_width)
            
        }
        
        goodButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.right.equalTo(self.snp_right)
            make.bottom.equalTo(self.snp_bottom)
            
            //重要约束
            make.width.equalTo(commentsButton.snp_width)
        }
        //中间评论按钮设置约束
        commentsButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            make.left.equalTo(retweetButton.snp_right)
            make.right.equalTo(goodButton.snp_left)
        }
        
        //白色竖线
        leftLine.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(retweetButton.snp_right)
            make.centerY.equalTo(self.snp_centerY)
        }
        
        rightLine.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(commentsButton.snp_right)
            make.centerY.equalTo(self.snp_centerY)
        }
        
    }
    
    
    
    
//    懒加载转发,评论,
    private lazy var retweetButton: UIButton = {
        let btn = UIButton (type: .Custom)
        
        btn.setTitle("转发", forState: UIControlState.Normal)
        btn.setTitleColor(UIColor (white: 0.95, alpha: 1.0), forState: UIControlState.Normal)
        btn.setImage(UIImage (named: "timeline_icon_retweet"), forState: UIControlState.Normal)
        
        return btn
        }()
    
    private lazy var commentsButton: UIButton = {
       let btn = UIButton(type: .Custom)
        
        btn.setTitle("评论", forState: UIControlState.Normal)
        btn.setTitleColor(UIColor (white: 0.95, alpha: 1.0), forState: UIControlState.Normal)
        btn.setImage(UIImage (named: "timeline_icon_comment"), forState: UIControlState.Normal)
        
        return btn
    }()
    
    private lazy var goodButton: UIButton = {
        let btn = UIButton (type: .Custom)

        btn.setTitle("赞", forState: UIControlState.Normal)
        btn.setTitleColor(UIColor (white: 0.95, alpha: 1.0), forState: UIControlState.Normal)
        btn.setImage(UIImage (named: "timeline_icon_like"), forState: UIControlState.Normal)
        
        
        return btn
        }()
    
    private func getLine() -> UIImageView{
    let imaView = UIImageView()
        imaView.image = UIImage (named: "timeline_card_bottom_line_highlighted")
        return imaView
    }
    

}





